package com.alphaking.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.alphaking.model.User;

/**
 * 平台入口管理
 * 
 * @author mwc
 *
 */
public class AdminInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {

		System.out.println(request.getSession().hashCode());
		User user = (User) request.getSession().getAttribute("adminUser");
		if (user == null) {
			response.sendRedirect("/learn/admin/toAdminLoginPage");
			return false;
		}
		return true;
	}

}
